﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Text;
using HotelSoft.HotelManagement_DTO;
namespace HotelSoft.HotelManagement_DAO
{
    class THONGKE_NAMDAO
    {
        public static DataTable KTMD_PHONG(object AbstractDTO)
        {
            THONGKE_NAMDTO dto = (THONGKE_NAMDTO)AbstractDTO;
            string sql = "SELECT SoPhong, count(*) as Soluot From PHIEUDANGKY where year(Ngayden)="+dto.NAM+"Group by SoPhong";
            return Config.AccessHelper.ExecuteQuery(sql);
        }

        public static DataTable KTMD_PHONG_Tong(object AbstractDTO)
        {
            THONGKE_NAMDTO dto = (THONGKE_NAMDTO)AbstractDTO;
            string sql = "SELECT count(*) From PHIEUDANGKY where year(Ngayden)=" + dto.NAM;
            return Config.AccessHelper.ExecuteQuery(sql);
        }

        public static DataTable KTDT_LOAIPHONG(object AbstractDTO)
        {
            THONGKE_NAMDTO dto = (THONGKE_NAMDTO)AbstractDTO;
            string sql = "SELECT lp.TenLP, sum(TongTien) as TC From PHIEUDANGKY pdk, HOADON_THANHTOAN hd, PHONG p, LOAIPHONG lp "+
                        "where lp.TenLP=p.TenLP and p.SoPhong=pdk.SoPhong and pdk.SoPDK=hd.SoPDK and year(NgayThanhToan)=" + dto.NAM + " Group by lp.TenLP";
            return Config.AccessHelper.ExecuteQuery(sql);
        }

        public static DataTable KTDT_LOAIPHONG_Tong(object AbstractDTO)
        {
            THONGKE_NAMDTO dto = (THONGKE_NAMDTO)AbstractDTO;
            string sql = "SELECT sum(TongTien) From HOADON_THANHTOAN where year(NgayThanhToan)=" + dto.NAM;
            return Config.AccessHelper.ExecuteQuery(sql);
        }
    }
}
